-------------------------------------------------------------
--					Add Procedure
-------------------------------------------------------------
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

IF EXISTS(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Customers_SaveCustomers]') AND type in (N'P', N'PC'))
BEGIN
DROP PROCEDURE [Customers_SaveCustomers]
END
GO

Create Procedure [dbo].[Customers_SaveCustomers]
(
	@CustomerName nvarchar(max),
	@PhoneNumber nvarchar(max),
	@CustomerDescription nvarchar(max)
)
AS
	if exists(select * from Customers WITH(NOLOCK) where CustomerName = @CustomerName)
		update Customers set
		PhoneNumber=@PhoneNumber,
		[Description]=@CustomerDescription,
		UpdateDate=GETDATE()
		where CustomerName = @CustomerName;
	else
		insert into Customers
		(
			CustomerName,
			PhoneNumber,
			[Description],
			IsDeleted,
			CreateDate,
			UpdateDate
		) 
		values
		(
			@CustomerName,
			@PhoneNumber,
			@CustomerDescription,
			0,
			GETDATE(), 
			GETDATE() 
		)
	